<?php
session_start();
include "../service/userService.php";
if(isset($_POST["user"])){
    $username = $_POST["user"];
    $pwd = $_POST["pwd"];
    $loggedIn = checkAdminAuthenticate($username,$pwd);
    
    if($loggedIn == 1 || $loggedIn == 2){
        
        if($loggedIn == 1){
            $admin = mysql_fetch_array(getAdminInfor($username));
            $_SESSION['loginuser'] = array($admin["USER_ID"],$admin["USER_NAME"],$admin["USER_TYPE"]);  
        }else{
            $mod = mysql_fetch_array(getModInfor($username));
            $_SESSION['loginuser'] = array($mod["USER_ID"],$mod["USER_NAME"],$mod["USER_TYPE"]);
        }
        
        echo "<script>window.location.href='../pc/personalInformation.php'</script>";        
    }else{
        echo "<script>window.location.href='../admin/login.php?msg=0'</script>";
    }
}else{
    //echo "<script>window.location.href='../admin/login.php?msg=0'</script>";
}


?>